﻿@model Moonglade.Web.Pages.Admin.EditPostModel

<div class="modal fade" id="unpublishPostModal" tabindex="-1" role="dialog" aria-labelledby="unpublishPostModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="unpublishPostModalLabel">@SharedLocalizer["Unpublish Post"]</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
                </button>
            </div>
            <div class="modal-body">
                <div class="alert alert-warning">@SharedLocalizer["Unpublishing this post will remove it from the public site and turn it into a draft. This will have impact on SEO. Please confirm."]</div>
                <p>
                    @Model.ViewModel.Title
                </p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">@SharedLocalizer["Cancel"]</button>
                <a class="unpublish-post-confirm btn btn-danger" href="javascript:UnpublishPost('@Model.ViewModel.PostId');">@SharedLocalizer["Confirm"]</a>
            </div>
        </div>
    </div>
</div>

<script>
    function UnpublishPost(postId) {
        callApi(
            `/api/post/${postId}/unpublish`,
            'PUT',
            {},
            (resp) => {
                blogToast.success('Post unpublished');
                location.reload();
            });
    }
</script>